<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="jakarta.tags.core" %>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>医生排班 - 医疗预约系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Microsoft YaHei', sans-serif;
        }
        
        body {
            background-color: #f5f5f5;
            min-height: 100vh;
        }
        
        .header {
            background-color: #4a90e2;
            color: white;
            padding: 15px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .header h1 {
            font-size: 24px;
        }
        
        .header .user-info {
            display: flex;
            align-items: center;
        }
        
        .header .user-info span {
            margin-right: 15px;
        }
        
        .header .logout-btn {
            color: white;
            text-decoration: none;
            padding: 5px 10px;
            background-color: rgba(255,255,255,0.2);
            border-radius: 4px;
            transition: background-color 0.3s;
        }
        
        .header .logout-btn:hover {
            background-color: rgba(255,255,255,0.3);
        }
        
        .container {
            display: flex;
            min-height: calc(100vh - 60px);
        }
        
        .sidebar {
            width: 200px;
            background-color: #333;
            color: white;
        }
        
        .sidebar ul {
            list-style: none;
        }
        
        .sidebar li {
            padding: 15px 20px;
        }
        
        .sidebar a {
            color: white;
            text-decoration: none;
            display: block;
            transition: background-color 0.3s;
        }
        
        .sidebar li:hover {
            background-color: #4a90e2;
        }
        
        .sidebar li.active {
            background-color: #4a90e2;
        }
        
        .content {
            flex: 1;
            padding: 20px;
        }
        
        .page-title {
            font-size: 20px;
            margin-bottom: 20px;
            color: #333;
        }
        
        .table-container {
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            overflow: hidden;
        }
        
        table {
            width: 100%;
            border-collapse: collapse;
        }
        
        th, td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid #eee;
        }
        
        th {
            background-color: #f8f9fa;
            font-weight: bold;
            color: #555;
        }
        
        tr:hover {
            background-color: #f8f9fa;
        }
        
        .status-badge {
            display: inline-block;
            padding: 3px 8px;
            border-radius: 4px;
            font-size: 12px;
        }
        
        .status-pending {
            background-color: #ffc107;
            color: #333;
        }
        
        .status-confirmed {
            background-color: #28a745;
            color: white;
        }
        
        .empty-message {
            text-align: center;
            color: #999;
            padding: 50px;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>医生排班管理</h1>
        <div class="user-info">
            <span>欢迎您，${loginDoctor.doctorName}</span>
            <a href="/doctorLogout" class="logout-btn">退出登录</a>
        </div>
    </div>
    
    <div class="container">
        <div class="sidebar">
            <ul>
                <li><a href="/doctor/workspace">工作台</a></li>
                <li class="active"><a href="/doctor/appointments">我的排班</a></li>
                <li><a href="/doctor/patients">病人管理</a></li>
            </ul>
        </div>
        
        <div class="content">
            <h2 class="page-title">我的排班信息</h2>
            
            <div class="table-container">
                <table>
                    <thead>
                        <tr>
                            <th>排班日期</th>
                            <th>时间段</th>
                            <th>科室</th>
                            <th>医院</th>
                            <th>状态</th>
                        </tr>
                    </thead>
                    <tbody>
                        <c:choose>
                            <c:when test="${not empty appointments}">
                                <c:forEach items="${appointments}" var="appointment">
                                    <tr>
                                        <td>${appointment.appointmentDate}</td>
                                        <td>${appointment.appointmentTime}</td>
                                        <td>${appointment.departmentName}</td>
                                        <td>${appointment.hospitalName}</td>
                                        <td>
                                            <span class="status-badge ${appointment.status == 0 ? 'status-pending' : 'status-confirmed'}">
                                                ${appointment.status == 0 ? '待预约' : '已预约'}
                                            </span>
                                        </td>
                                    </tr>
                                </c:forEach>
                            </c:when>
                            <c:otherwise>
                                <tr>
                                    <td colspan="5" class="empty-message">暂无排班信息</td>
                                </tr>
                            </c:otherwise>
                        </c:choose>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</body>
</html>